<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <title>#{bundle_contTemDetail_vi.Title}</title>
        <script>
            function confirmComplete() {
                var answer = confirm("Bạn có chắc chắn muốn xóa bản ghi này?");
                if (answer == true)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        </script>
    </h:head>
    <h:body> 
        <link type="text/css" rel="stylesheet" href="../css/main.css" />        
        <style type="text/css">
            .ui-widget{font-size:95% !important;}
            .ui-layout-unit-content{background-color: #E5E5E5;border-width: 0px}        
            .ui-widget{border-width: 0px;color: red}
        </style>
        <div align="center" id="bodyForm" >            
            <div style="width: 100%;">
                <p:layoutUnit id="top" position="north" size="auto">
                    <ui:insert name="menu">
                        <ui:include src="../../templates/menu.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>
                <p:layoutUnit id="center" position="center" size="400">
                    <h1 class="headerbar">Quản lý Content Template</h1>
                    <p:outputPanel id="pnP" style="width: 100%;">                        
                        <p:growl id="message"/>
                        <h:panelGrid columns="2" style="width: 100%;">
                            <p:panel header="#{bundle_contTemDetail_vi.TitleTableContTem}" style="margin-top: 10px;">
                                <h:form>
                                    <p:dataTable id="tblSys" 
                                                 var="ct" 
                                                 value="#{contTemController.list}"
                                                 rowKey="#{ct.id}"                                                                                                 
                                                 style="width: 100%;" paginator="true" rows="10"
                                                 selection="#{contTemDetailController.currentTemp}" 
                                                 selectionMode="single"> 
                                        <p:ajax event="rowSelect" listener="#{contTemDetailController.rowSelect()}"   
                                                update=":pnDetail :formAdd" />

                                        <p:column headerText="#{bundle_contTemDetail_vi.Id}">
                                            <h:outputText value="#{ct.id}" style="float: right;"/>
                                        </p:column>

                                        <p:column headerText="#{bundle_contTemDetail_vi.TemplateName}">
                                            <h:outputText value="#{ct.name}" style="float: right;"/>
                                        </p:column>

                                        <p:column headerText="#{bundle_contTemDetail_vi.Status}">
                                            <h:outputText value="#{ct.status eq 1 ? bundle_contTemDetail_vi.Status1:bundle_contTemDetail_vi.Status0}" style="float: right;"/>
                                        </p:column>
                                    </p:dataTable>   
                                </h:form>
                            </p:panel>                           
                            <p:panel style="margin-top: 10px;" id="pnDetail">
                                <p:growl id="messageDetail"/>
                                <h:form id="form" style="width: 100%;">                                
                                    <p:dialog modal="true" widgetVar="statusDialog" header="#{bundle_contTemDetail_vi.Searching}"   
                                              draggable="false" closable="false">  
                                        <p:graphicImage value="../../images/ajax-loader.gif" />  
                                    </p:dialog>
                                    <div align="center" style="margin-top: 10px;margin-bottom: 10px;margin-left: 10px;">                                        
                                        <p:commandButton value="#{bundle_contTemDetail_vi.Add}" onclick="dlgAdd.show()" icon="ui-icon ui-icon-plusthick" rendered="#{contTemDetailController.addStatus}"/>
                                    </div>
                                </h:form>                            
                                <h:form style="width: 100%" id="form2">
                                    <p:panel header="#{bundle_contTemDetail_vi.TitleTableContTemDetail}" id="pnltree">
                                        <p:dataTable id="tblSys" 
                                                     var="ctd" 
                                                     value="#{contTemDetailController.list}"
                                                     rowKey="#{ctd.id}"                                                                                                 
                                                     style="width: 100%;" paginator="true" rows="10">                                        
                                            <p:column headerText="#{bundle_contTemDetail_vi.Id}">
                                                <h:outputText value="#{ctd.id}" style="float: right;"/>
                                            </p:column>

                                            <p:column headerText="#{bundle_contTemDetail_vi.TemplateId}">
                                                <h:outputText value="#{ctd.contentTemId}" style="float: right;"/>
                                            </p:column>

                                            <p:column headerText="#{bundle_contTemDetail_vi.PropertyName}">
                                                <h:outputText value="#{ctd.propertyName}" style="float: right;"/>
                                            </p:column>

                                            <p:column headerText="#{bundle_contTemDetail_vi.Status}">
                                                <h:outputText value="#{ctd.status eq 1 ? bundle_contTemDetail_vi.Status1:bundle_contTemDetail_vi.Status0}" style="float: right;"/>
                                            </p:column>
                                            <p:column headerText="#{bundle_contTemDetail_vi.Edit}" style="width: 10px">
                                                <div align="center">
                                                    <p:commandButton style="height: 20px;width: 20px;" styleClass="ui-icon ui-icon-pencil" onclick="dlgEdit.show()" update=":formEdit" actionListener="#{contTemDetailController.ctdFromTable()}"/>
                                                </div>
                                            </p:column>
                                            <p:column headerText="#{bundle_contTemDetail_vi.Delete}" style="width: 10px">                                            
                                                <div align="center">
                                                    <p:commandButton style="height: 20px;width: 20px;" styleClass="ui-icon ui-icon-trash" onclick="return confirmComplete()" update=":pnP" action="#{contTemDetailController.remove()}"/>
                                                </div>
                                            </p:column>
                                        </p:dataTable>                                    
                                    </p:panel>
                                </h:form>   
                            </p:panel>
                        </h:panelGrid>
                        <!--dialog them add-->
                        <p:dialog modal="true" widgetVar="dlgAdd" header="#{bundle_contTemDetail_vi.HeaderDlgAdd}" resizable="false">
                            <h:form style="width: 100%" id="formAdd">
                                <p:growl id="message1"/>
                                <h:panelGrid columns="2">  
                                    <h:outputText value="#{bundle_contTemDetail_vi.TemplateName}: "/> <h:outputText value="#{contTemDetailController.currentTemp.name}"/>
                                    <h:outputText value="#{bundle_contTemDetail_vi.PropertyName}: "/> <p:inputText value="#{contTemDetailController.currentCtd.propertyName}"/>

                                    <h:outputText value="#{bundle_contTemDetail_vi.Status}: "/> 
                                    <p:selectOneMenu value="#{contTemDetailController.currentCtd.status}" >
                                        <f:selectItem itemValue="1" itemLabel="#{bundle_contTemDetail_vi.Status1}"/>
                                        <f:selectItem itemValue="0" itemLabel="#{bundle_contTemDetail_vi.Status0}"/>
                                    </p:selectOneMenu>
                                    <h:outputText value=""/>
                                    <h:panelGrid columns="2">
                                        <p:commandButton value="#{bundle_contTemDetail_vi.Save}" style="width: 60px" action="#{contTemDetailController.insert()}" update=":pnP"/>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </h:form>
                        </p:dialog>
                        <!--dialog edit-->
                        <p:dialog modal="true" widgetVar="dlgEdit" header="#{bundle_contTemDetail_vi.HeaderDlgEdit}" resizable="false" >
                            <h:form style="width: 100%" id="formEdit">
                                <p:growl id="message1"/>
                                <h:panelGrid columns="2">                                    
                                    <h:outputText value="#{bundle_contTemDetail_vi.TemplateName}: "/> <h:outputText value="#{contTemDetailController.currentTemp.name}"/>
                                    <h:outputText value="#{bundle_contTemDetail_vi.PropertyName}: "/> <p:inputText value="#{contTemDetailController.currentCtd.propertyName}"/>

                                    <h:outputText value="#{bundle_contTemDetail_vi.Status}: "/> 
                                    <p:selectOneMenu value="#{contTemDetailController.currentCtd.status}" >
                                        <f:selectItem itemValue="1" itemLabel="#{bundle_contTemDetail_vi.Status1}"/>
                                        <f:selectItem itemValue="0" itemLabel="#{bundle_contTemDetail_vi.Status0}"/>
                                    </p:selectOneMenu>
                                    <h:outputText value=""/>
                                    <h:panelGrid columns="2">
                                        <p:commandButton value="#{bundle_contTemDetail_vi.Save}" style="width: 60px" action="#{contTemDetailController.update()}" update=":pnP"/>
                                    </h:panelGrid>                                    
                                </h:panelGrid>
                            </h:form>
                        </p:dialog>                        
                    </p:outputPanel>
                </p:layoutUnit>
                <p:layoutUnit id="bottom" position="bottom" size="60">
                    <ui:insert name="footer">
                        <ui:include src="../../templates/footer.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>
            </div>
        </div>
    </h:body>
</html>

